// pages/index/index.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    scene:{},
    spot:[],
    base_img:'',
    path:[],
    showDialog:false,
    imgSrc:'',
    brand:'',
    history:'',
    skill:'',
    art:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    const that = this
    app.api.get(app.getUrl('defaultscene')).then((res)=>{
      console.log(res)
      that.setData({
        scene:res.scene,
        spot:res.spot,
        path:res.path,
        base_img:res.base_img,
        brand:res.brand,
        history:res.history,
        skill:res.skill,
        art:res.art,
      })
       if(res.scene.helper) {
         let helper_img = res.base_img+res.scene.helper;
         wx.setStorageSync('helper_img', helper_img)
       }
 
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    console.log('到底了')
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  onShareTimeline(){

  },// 工艺
  sceneDetail() {
    let src= this.data.skill;
    wx.navigateTo({
      url: '/pages/webs/skill/index?src='+encodeURIComponent(src),
    })
  },
  allSpot() { //品牌渊源
    let src= this.data.brand;
    wx.navigateTo({
      url: '/pages/webs/brand/index?src='+encodeURIComponent(src),
    })
  },//直播
  publicService() { //公共服务
    //todo 直播
    // wx.showToast({
    //   title: '直播功能暂未开放',
    //   icon:'none'
    // })
    wx.navigateTo({
      url: '/pages/live/index',
    })
  },
  onClickHide() {
    this.setData({
      showDialog:false
    })
  },//历史传承
  manualmap() {
    let src = this.data.history;
    wx.navigateTo({
      url: '/pages/webs/history/index?src='+encodeURIComponent(src),
    })
  },//点击游览路线
  cruise(e) {
    console.log(e);
    let id = e.currentTarget.dataset.id;
    wx.reLaunch({
      url: '/pages/map/index?path='+id,
    })
  },//能攻匠人
  viewSpot(e) {
    console.log(e);
    let sid=e.currentTarget.dataset.sid;
    let src = this.data.art+'/'+sid;
    wx.navigateTo({
      url: '/pages/webs/art/index?src='+encodeURIComponent(src),
    })
  }
})